#ifndef CVX_MAT_H
#define CVX_MAT_H 1

#include "opencv2/core/core.hpp"
#include "opencv2/core/core_c.h"
#include "nvmath.h"
#include <iostream>
using std::ostream;
using std::endl;

namespace cvx
{
	template<class T> class CvxMat
	{
	public:
		CvxMat(const cv::Mat* m = 0)
		{
			assert(m->dims == 2);
			for (int y = 0; y<4 && y<m->rows; ++y)
			{
				for (int x = 0; x<4 && x<m->cols; ++x)
				{
					m_m44._array[y*4+x] = (float)m->at<T>(y, x);
				}
			}
		}
		~CvxMat(){}

	private:
		nv::matrix4f m_m44;		
	};
	typedef CvxMat<double> CvxMat_d;
	typedef CvxMat<float>  CvxMat_f;


	//easy watch 1D Mat
	template<class T> class TestMat
	{
	public:
		TestMat(const cv::Mat* m = 0)
		{
			assert(m->dims == 2);
			if (m->rows == 1)
			{
				for (int x = 0; x<m->cols && x<1080; ++x)
				{
					m_data[x] = m->at<T>(0, x);
				}
			}
			else if (m->cols == 1)
			{
				for (int y = 0; y<m->rows && y<1080; ++y)
				{
					m_data[y] = m->at<T>(y, 0);
				}
			}
		}
		~TestMat(){}

	private:
		T m_data[1080];
	};

	typedef TestMat<double> TestMat_d;
	typedef TestMat<float> TestMat_f;
}



#endif